#ifndef _RADAR_TEST_H
#define _RADAR_TEST_H

#include "CTestReport.h"
#include "Logger.h"
#include "radar_detect.h"
#include <QStringList>
#include <QThread>
#include <QVector>
#include <qcontainerfwd.h>
#include <qobject.h>
#include <qtmetamacros.h>
#include <stdint.h>

class CThreadRadarTest : public QThread {
  Q_OBJECT

public:
  CThreadRadarTest(QWidget *parent){};
  ~CThreadRadarTest(){};

private:
  void GetRadarData(QString video_file, QVector<uint32_t> &radar_data);

public:
  void SetStop(bool stop) { stop_ = stop; };
  bool stop_ = true;
  int SetFileList(QStringList list) {
    file_list_ = list;
    return 0;
  };
  int SetOutputFolder(QString Folder) {
    folder_output_ = Folder;
    return 0;
  };

public:
  QVector<uint32_t> radar_data_;
  int radar_index_;
  bool soc_on_;
  uint32_t soc_on_count_;
  SocTrigInfo_t soc_trig_info_;

private:
  QStringList file_list_;
  QString folder_output_;
  void UpdateText(QString str) { emit setText(str); };
  void UpdateProcess(int process) { emit finished(process); };
  uint64_t radar_interval_;
  QVector<CTestReport::EventInfo_t> alg_resl_;
  QVector<CTestReport::EventInfo_t> mark_info_;
  uint32_t trig_index_;
  bool has_car_;
  bool park_out_;
public:
  static int OnSocTrig(int soc_state, void *param);
  static int OnRadarTrig(uint16_t *dist, uint16_t *amp, void *param);
  int OnPowerOn(QLogger &logger);
  int OnParkIn(QLogger &logger, bool has_car, bool car_change);
  int OnParkStable(QLogger &logger, bool has_car, bool car_change);
  int OnParkOut(QLogger &logger, bool has_car, bool car_change);
  int OnParkFree(QLogger &logger, bool has_car, bool car_change);
  int OnSnapShot(QLogger &logger, bool has_car);
  int OnAlarm(QLogger &logger, bool has_car);
  uint64_t GetRadarInterval(QString video_file, uint32_t radar_num);
  int OnAlgResultProcess(QLogger &logger);
  bool GetAlgResultFromMarkInfo(QVector<CTestReport::EventInfo_t> info,
                                uint32_t idx);
  int DoBeforeTest(QString file_name, CTestReport *report, QLogger &logger);
  int AddAlgResult(uint32_t id, uint8_t type);

protected:
  void run();
signals:
  void finished(int process);
  void setText(QString str);
};

#endif